package solution;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author : wenchao.long
 * @date : Created in 2023-12-19 下午 7:43 周二
 * @description :
 * 		<a href="https://leetcode.cn/problems/longest-substring-without-repeating-characters/description/">无重复字符的最长子串</a>
 */
public class No3 {

	public int lengthOfLongestSubstring(String s) {
		int offset = 0;
		int maxLength = 0;
		Map<Character, Integer> map = new HashMap<>();

		for (int i = 0; i < s.length(); ++i) {
			char c = s.charAt(i);
			if (map.containsKey(c)) {
				if (map.get(c) >= offset) {
					offset = map.get(c) + 1;
				}
			}
			map.put(c, i);
			maxLength = Math.max(maxLength, i - offset + 1);
		}
		return maxLength;
	}

	public static void main(String[] args) {
//		Integer y1 = 2023;
//		Integer y2 = 2027;
//		List<Integer> result = new ArrayList<>();
//		while (!y1.equals(y2)) {
//			result.add(y1);
//			y1 += 1;
//		}
//		result.add(y2);
//		System.out.println(result);

		List<Integer> l1 = new ArrayList<>();
		l1.add(1);
		l1.add(2);
		l1.add(3);
		l1.add(4);

		List<Integer> collect = Stream.iterate(0, x -> x + 1).limit(5).map(x -> x + 1).collect(Collectors.toList());
		System.out.println(collect);
	}
}
